#ifndef _SEGGER_H_
#define _SEGGER_H_

#include "slab.h"
#include "datrie.h"
#include "context.h"
#include "model.h"
#include "result.h"

#define SEG_LEN_MAX		(1<<24)

typedef struct segger{
	unsigned int		off;	//cur offset
	unsigned int		len;	//input buf len
	const char *		buf;	//input buf
	mod *				modp;	//hmm
	slab *				slabp;	//slab
	dat *				datp;	//double array trie
	result *			resp;	//result
	unsigned char		busy;	//if busy					--only used in hiseg
	struct list_head	list;	//list as a node of hiseg   --only used in hiseg
}segger;

segger * segger_new(dat * datp, ctx * ctxp, ctx * nrp, ctx * nsp, ctx * trp);
int segger_do(segger * p, const char * input, unsigned int len);
const char * segger_next_res(segger * p, unsigned int * lenp);
int segger_free(segger * p);

/* error code list */
#define SEG_OK				(0)
#define SEG_EMPTY			(1)

#define SEG_INPUT_ERR		(-1)
#define SEG_DECODE_ERR		(-2)
#define SEG_PUSHTOK_ERR		(-3)
#define SEG_TOKCRUSH_ERR	(-4)
#define SEG_PUSHMM_ERR		(-10)
#define SEG_DATFETCH_ERR	(-20)
#define SEG_MMSEG_ERR		(-100)

#endif
